package com.wangsanfei.ihg.wechat.interceptor;

import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;
import com.wangsanfei.config.ConstConfig;
import com.wangsanfei.util.StringUtils;

public class AuthInterceptor implements Interceptor{

	
	public void intercept(Invocation ai) {
		
		String actionKey=ai.getActionKey();
		if(actionKey.indexOf("/manage/")>-1){
			String userType=(String)ai.getController().getSession().getAttribute(ConstConfig.SESSION_USER_TYPE);
			if(!StringUtils.isEmpty(userType)){
				ai.invoke();
			}else{
				ai.getController().redirect("/manage");
			}
		}else{
			ai.invoke();
		}
		
	}

}
